package com.face;

public class RespMsg {

    private int code; // 0 为正常
    private String msg;
    private Object data;

    private final static String none = "";

    public static RespMsg build(Object o) {
        return new RespMsg(0, none, o);
    }

    public static RespMsg error(int code, String msg) {
        return new RespMsg(code, msg, null);
    }

    public static RespMsg error(String msg) {
        return new RespMsg(-1, msg, null);
    }


    private RespMsg(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public boolean isError() {
        return code != 0;
    }
}
